home *** CD-ROM | disk | FTP | other *** search
- Program PrintDemo;
- {This is a simple example of how to use the Printing Manager. It is
- currently set up for Turbo Pascal, but can easily be made to work
- with LS Pascal, TML Pascal, or MPW Pascal with simple changes in
- compiler directives.}
- {$U-}
-
- USES Memtypes,QuickDraw,OSIntf,ToolIntf,PackIntf,MacPrint;
-
- VAR
- PrintingPort:GrafPtr;
- PrintRecHandle:THPrint;
- PrintRecPtr:TPPrint;
- PrintRec:TPrint;
- PrintPort:TPPrPort;
- PRect:rect;
- PrintStatusRec:TPrStatus;
-
-
- PROCEDURE Debug (Message : str255; n : LongInt);
- {Writes debugging information in the Menu Bar.}
- CONST
- Top = 0;
- Left = 375;
- Bottom = 18;
- Right = 500;
- VAR
- d : rect;
- ticks : LongInt;
- tPort,ScreenPort : GrafPtr;
- str:string;
- BEGIN
- GetPort(tPort);
- GetWMgrPort(ScreenPort);
- SetPort(ScreenPort);
- SetRect(d, Left, Top, Right, Bottom);
- EraseRect(d);
- MoveTo(Left, Top + 15);
- DrawString(Message);
- IF n <> -1 THEN BEGIN
- DrawString(' ');
- NumToString(n,str);
- DrawString(str);
- END;
- delay(30, ticks);
- SetPort(tPort);
- END;
-
-
- PROCEDURE init;
- {Not required when using LS Pascal}
- BEGIN
- InitGraf(@ThePort);
- InitFonts;
- InitWindows;
- InitMenus;
- TEInit;
- InitCursor;
- END;
-
- PROCEDURE Draw;
- {Draws a triangle. Replace with your own drawing routine.}
- BEGIN
- MoveTo(100,100);
- LineTo(200,100);
- LineTo(150,200);
- LineTo(100,100);
- END;
-
- PROCEDURE ErrCheck;
- VAR
- err:integer;
- ticks:LongInt;
- BEGIN
- err:=PrError;
- IF err<0 THEN BEGIN
- SysBeep(1);
- debug('Print Error =',err);
- delay(300,ticks);
- END;
- END;
-
- PROCEDURE Print;
- VAR
- err:Integer;
- result:boolean;
- BEGIN
- PrOpen; ErrCheck; debug('PrOpen',-1);
- PrintRecPtr:=@PrintRec;
- PrintRecHandle:=@PrintRecPtr;
- PrintDefault(PrintRecHandle); debug('PrintDefault',-1);
- prect:=PrintRec.prInfo.rPage;
- result:=PrJobDialog(PrintRecHandle); debug('PrJobDialog',-1);
- IF result THEN BEGIN
- PrintPort:=PrOpenDoc(PrintRecHandle,NIL,NIL); ErrCheck; debug('PrOpenDoc',-1);
- PrOpenPage(PrintPort,NIL); ErrCheck; debug('PrOpenPage',-1);
- Draw; debug('Drawing',-1);
- PrClosePage(PrintPort); ErrCheck; debug('PrClosePage',-1);
- PrCloseDoc(PrintPort); ErrCheck; debug('PrCloseDoc',-1);
- IF PrintRecHandle^^.prJob.bJDocLoop=bSpoolLoop
- THEN PrPicFile(PrintRecHandle,NIL,NIL,NIL,PrintStatusRec);
- END;
- PrClose; debug('PrClose',-1);
- END;
-
- BEGIN
- Init;
- Print;
- END.
-